package sk.fiit.vppj.eventmanager.core;

import java.io.File;
/**
 * Helper class for common tasks
 * @author Marek
 *
 */
public final class Utils {
	/**
	 * Method for getting extension from file
	 * @param f - file to which you want to know extension
	 * @return Returns extension of file
	 */
	public static String getExtension(File f) {
		String ext = null;
		String s = f.getName();
		int i = s.lastIndexOf( '.' );

		if( i > 0 && i < s.length() - 1 ) {
			ext = s.substring( i + 1 ).toLowerCase();
		}
		return ext;
	}
	
	/**
	 * Checks the string represents number
	 * @param string 
	 * @return whether string can be string
	 */
	public static boolean isNumber(String string) {
		return string.matches( "^\\d+$" );
	}

}
